home *** CD-ROM | disk | FTP | other *** search
/ New Star Software Collection / NSS_Collection.iso / 3-004 ms visual basic pro 30 / 4.imz / 4.IMA / VB.LE_ / VB.bin (.txt)
Microsoft Lesson  |  1993-04-28  |  277KB  |  2,464 lines

  1. Out of Memory xxx
  2. File Missing
  3. Unrecognized Error
  4. Microsoft CBT
  5. &Instructions
  6. &Back
  7. &Menu
  8. &Summary
  9. E&xit Tutorial
  10. Cancel: Esc
  11. Options
  12. ebugging Your Application
  13. dding Menus5
  14. A.How to Use the Learning Visual Basic Tutorial 
  15. Opens this window.-
  16. Jumps to the SummaryA
  17. for that lesson.
  18. Returns to the Menu.t
  19. )Click a lesson name to start that lesson.
  20. (To learn how to use the tutorial, click A
  21. the Instructions button.!
  22. Closes the Options A
  23. menu.X
  24. +When you're done reading the Instructions, A$click the Close Instructions button.8
  25. Closes the tutorial andA
  26. returns to Visual Basic.s
  27. )Click a lesson name to start that lesson.
  28. 'To learn how to use the tutorial, clickA
  29. the Instructions button.;
  30. To go forward in a lesson,A
  31. click the Next button.  $
  32. reating an Application#
  33. ow Visual Basic Works&
  34. Learning Microsoft Visual Basic%
  35. sing Color and Graphics%
  36. Returns to theA
  37. previous step.
  38. Options<
  39. To go backward in a lesson,A
  40. click the Back button.  +
  41. riting Event-DrivenB
  42. Programs5
  43. A.How to Use the Learning Visual Basic Tutorial 
  44. nstructions
  45. Clicking the Options button 
  46. opens a menu of different 
  47. ways to get around in the 
  48. tutorial, as shown inA
  49. the diagram at right.0
  50. Working with 
  51. orms A
  52. and Controls&
  53. Learning Microsoft Visual Basic.
  54. A'Select a lesson or choose Instructions.j
  55. A red arrow  
  56. points to an instruction 
  57. 'for you to follow to continue with the A    tutorial.    &Options
  58. E&xit
  59. &Back
  60. &Instructions
  61. &Menu
  62.     &Summary
  63. E&xit Tutorial
  64. Cancel: Esc
  65. C&lose Instructions
  66. (    O    t
  67. .    R    n
  68. wwwwwwwwwwwwwwwwwww
  69. wwwwwwwwwwwwwwwwwww
  70. wwwwwww
  71. wwwxw
  72. wwwwwwwwwwwwwwwwwww
  73. wwwwwwwwwwwwwwwwwww
  74. wwwwwwwwwwwwwx
  75. UUUUUUUUUUPx
  76. UUUUUUUUUUPx
  77. wwwwwwwwwwwwwwwwwww
  78. wwwwwwwwwwwwwwwwwww
  79. wwwwwww
  80. wwwww
  81. UUUUUUUUUUUWx
  82. UUUUUUUUUUUWw
  83. UUUUUUUUUUUUx
  84. wwwwwwwwwwwwwwwwwww
  85. wwwwwwwwwwwwwwwwwww
  86. UUUUx
  87. UwwUUUUWwuW
  88. wwwwwwwwwwwwwwwwwww
  89. wwwwwwwwwwwwwwwwwww
  90. wwwwwwwwwwwwwww
  91. wwwwwww
  92. UUUUUUUUUUUU
  93. UUUUUUUUUUUU
  94. wwwwwwwwwwwwwwwwwww
  95. wwwwwwwwwwwwwwwwwww
  96. wwwwwwwww
  97. UUUUUUUUUUUUUU
  98. wwwwwwwwwwwwwwwwwww
  99. wwwwwwwwwwwwwwwwwww
  100. UUUUUUUU
  101. UUUUUUUUPf`
  102. UUUUUUUP
  103. Pwwwwwwww
  104. wwwwwp
  105. UUUPP
  106. wwwwwwwwwwwwwwwwwww
  107. wwwwwwwwwwwwwwwwwww
  108. UUUUP
  109. UUUUP
  110.     Form1.frmA
  111. Countries of the World
  112. Summary:,
  113. ile    
  114. dit    
  115. ountry
  116. Guinea
  117. Population
  118. GRID.VBXA
  119. $2,400 Million
  120. (This lesson introduced you to the Visual
  121. Basic design environment. 
  122. .In the following lessons, you'll learn how to @(use Visual Basic to create applications.
  123. Income per Capita
  124. $330.17
  125. OLECLIEN.VBXA
  126. Form1
  127. Form1B
  128. Form1
  129. Form2.
  130. ile     
  131. dit     
  132. ountry
  133. Next Country
  134. Next Country:
  135. Invalid Country
  136. Label1
  137. <To help you review your code quickly, Visual Basic provides:
  138. Automatic syntax checking
  139. Debugging tools
  140. A Debug window
  141. A    cmdCancel
  142. Text1
  143. %Visual Basic includes an easy-to-use 
  144. language
  145.  that is compatible with
  146. HVisual Basic for MS-DOS, QBasic, Basic Compiler 7.1, and other Microsoft@+Basic products.  Language features include:    
  147. Form1 B
  148. Form:
  149. You use the 
  150. Toolbox to draw
  151. controls on aA
  152. form.F
  153. cmdCancel_Click 
  154.    NextCountry.
  155. HideA
  156. End Sub
  157. AutoRedraw
  158. A    BackColor
  159. BorderStyle
  160. Form1
  161. As a dialog box
  162. ClipControls
  163. Property)
  164. Step through linesA
  165. or procedures.
  166. ControlBox)
  167. A"Form1.ForeColor = RGB(0, 255, 255)
  168. DrawMode
  169. A    DrawStyle
  170. A    DrawWidth
  171. Enabled-
  172. Integer
  173. Single
  174. DoubleA
  175. Variant
  176. False
  177. &80000005&
  178. 2 - Sizable
  179. Caption
  180. 13 - Copy Pen
  181. A    0 - Solid
  182. Sweden
  183. ountry
  184. Controls
  185. C are tools such as boxes, buttons, and labels you draw on a form to
  186. Kget input or to display output.  They also add visual appeal to your forms.@
  187. You can choose 
  188. the View Form 
  189. button to display A
  190. a form.7
  191. .A module contains declarations and procedures.A
  192. Currency
  193. String
  194. Japan@
  195. Instead of crowding your formA
  196. with command buttons . . .
  197. dd Watch...
  198. ext Country=
  199. @:You design menus for your forms in the Menu Design window.
  200. Loops<
  201. Print 
  202. UCase(
  203. Country
  204. A"Numerous math and string functions
  205. tion:P
  206. Visual Basic displays a 
  207. message when it findsA
  208. an error in your syntax.
  209. (none)
  210. nstant Watch...
  211. alls...!
  212. ext Statement6
  213. Set or show the next statementA
  214. to be executed.M
  215.  Set and display watch variables.A$List active procedures during break.
  216. Manage breakpoints.T
  217. The Visual Basic language
  218.     Menu bars
  219. The Color palette
  220. hortcut:
  221. elpContextID:
  222. Visual Basic also provides a 
  223. Color palette
  224. ! with 48 standard colors you can @Iuse to add color to your forms.  Visual Basic supports 256-color systems._
  225. Set breakpoints, view Instant 
  226. Watch, display the Calls A
  227. window, or step through code.
  228. Population
  229. Canada
  230. Next Country
  231. <To help you review your code quickly, Visual Basic provides:
  232. Automatic syntax checking
  233. Debugging tools
  234. Microsoft Visual Basic
  235. Expected: =
  236. Debug Window[Form1]H
  237. Sub Form_GotFocus ( )
  238. !   Form1.ForeColor = RGB(128,0,0)A
  239. End SubE
  240. The Immediate
  241. pane is used
  242. to execute singleA
  243. lines of code.r
  244. The Default button resets 
  245. the colors of a selected 
  246. object to the default colors A
  247. used in Visual Basic.P
  248. This box shows the current textA(color (text is limited to solid colors).
  249. Open or saveA
  250. a project.
  251. Visual Basic [design]
  252. A     Options \
  253. Or choose the View
  254. Code button to display
  255. the Code window for A
  256. a module or a form.q
  257. ATo make an application respond to user actions or system events, @+you write code for your forms and controls.h
  258. DIn applications with many commands, Visual Basic lets you group your
  259. commands on a 
  260. menu bar@
  261. :You set the properties of forms and controls by using the 
  262. CProperties window.  Properties specify the initial values for such @,characteristics as size, name, and position.^
  263. BThe Visual Basic toolbar provides shortcuts for many common design@
  264. and debugging commands.>
  265. Open the Menu
  266. Design window or theA
  267. Properties window.#
  268. Open a
  269. new formA
  270. or module.B
  271. Sub Form_Load ( )
  272.    Text1.text 
  273. "Colombia" A
  274. End Subs
  275. EVisual Basic provides many tools that you can use to design graphical@)applications. This lesson will introduce:
  276. ClickJ
  277. You write code for 
  278. your applications 
  279. in the Code window.B
  280. Proc:
  281. GotFocus
  282. Object:
  283. Form2
  284. A+A project can also contain custom controls.,
  285. @)You can use forms in many different ways:
  286. Clicking the Options button 
  287. opens a menu of different 
  288. ways to get around in the 
  289. tutorial, as shown inA
  290. the diagram at right.M
  291. Do While
  292. Print
  293.    I 
  294. Project1
  295. Menu Design Window
  296. Properties?
  297. As an illustrated introductionA
  298. screen to an application
  299. Countries of the World"
  300.  Next Statement
  301. dit Watch...
  302. rocedure Step
  303. iA    ngle Step
  304. oggle Breakpoint
  305. How Visual Basic Worksw
  306. -Click the Next button ( > ) to continue.  To 
  307. *return to the Menu or exit Learning VisualA
  308. Basic, click Options.
  309. )Press the PAGE DOWN key to continue with 
  310. (this lesson.  To choose another part of A.Learning Visual Basic or to exit, press ALT+O.
  311. Opens this window.-
  312. Jumps to the SummaryA
  313. for that lesson.
  314. Returns to the Menu.!
  315. Closes the Options A
  316. menu.%
  317. Returns to theA
  318. previous step.
  319. OptionsX
  320. +When you're done reading the Instructions, A$click the Close Instructions button.
  321. SettingV
  322. (. . . you can organize your commands on A%a menu bar along the top of the form.k
  323. <To help you review your code quickly, Visual Basic provides:
  324. Automatic syntax checkingd
  325. &Click the Menu button to return to the
  326. +Learning Visual Basic Menu.  To exit, clickA
  327. Options.
  328. Seven data typesz
  329. The Properties window lists 
  330. all the properties and their 
  331. settings for the currently A
  332. selected form or control.(
  333. As a document in A
  334. an applicationL
  335. The Watch pane
  336. displays the current 
  337. values of watch A
  338. expressions.
  339. project
  340. > is the collection of forms, modules, and custom controls that
  341. Fmakes up an application.  The Project window lists all the files in an@
  342. application.8
  343. Closes the tutorial andA
  344. returns to Visual Basic.$
  345. ear All Breakpoints5
  346. A.How to Use the Learning Visual Basic Tutorial 5
  347. A.How to Use the Learning Visual Basic Tutorial 
  348. A    7,269,000
  349. $2,400,000,000
  350. EYou create forms to serve as the interface of your application.  Each@Bform is a window that displays controls, graphics, or other forms.@
  351. [Form1.frm] BackColor: 0A
  352. [Form1.frm] ForeColor: 16776960
  353. @ includes the controls and code associated with that form.  When
  354. Gyou want to share code throughout a project, you can put that code in a
  355. module@
  356. If...Then...Else blocksv
  357.  Pop 
  358.  GNP 
  359.    Income 
  360.  GNP 
  361.    Income 
  362. End If?
  363. As an illustrated introductionA
  364. screen to an application]
  365. &This box shows the current foreground 
  366. %and background colors of the selectedA
  367. object.
  368. Module1.basB
  369.     Form1.frmB
  370. Form1B
  371. nabled
  372. isible
  373. indow List
  374. hecked
  375. To go forward in a lesson,A
  376. click the Next button.  <
  377. To go backward in a lesson,A
  378. click the Back button.  X
  379. (A form file contains the description of A'a form and the code associated with it.
  380. As a dialog boxj
  381. A red arrow  
  382. points to an instruction 
  383. 'for you to follow to continue with the A    tutorial.B
  384. Projects
  385. Forms and controls
  386. Modules_
  387. ,To return to the Learning Visual Basic Menu,A*press the SPACEBAR.  To exit, press ALT+O.
  388. You can display this
  389. window by choosing the
  390. Menu Design command 
  391. from the Window menu or
  392. choosing the Menu DesignA
  393. button on the toolbar..
  394. ile     
  395. dit     
  396. ountry
  397. EBy combining the Visual Basic forms, tools, and programming language,@7you can build powerful applications quickly and easily.<
  398. Start, break, or 
  399. end execution A
  400. of an application.c
  401. ile   
  402. dit   
  403. iew   
  404. un   
  405. ebug   
  406.     ptions   
  407. indow   
  408. elp    &Options
  409. View Form
  410. View Code
  411. Cancel
  412. Next Country
  413. Add Country
  414. Edit Country
  415. Insert
  416. Delete
  417. Default
  418. Custom Colors >>
  419. &Back
  420. &Instructions
  421. &Menu
  422.     &Summary
  423. E&xit Tutorial
  424. Cancel: Esc
  425. &Close Instructions
  426. wwwwwwwwp
  427. wwwwwwwwp
  428. wwwww
  429. wwwwwwwwp
  430. wwwwwwwwp
  431. wwwwwwwwwwwwp
  432. wwwwwwwwwwwwp
  433. wwwwwwwwwwwwpwwwwwwwwwwwww
  434. wwwwwwwwwwwwp
  435. wwwwwwwwwwww
  436. wwwwwwwwwwwwpwwwwwwwwwwwww
  437. wwwwwwwwwwwwp
  438. wwwwwwwwwwww
  439. wwwwwwwwwwwwpwwwwwwwwwwwww
  440. wwwwwwwwwwwwp
  441. wwwwwwwwwwww
  442. wwwwwwwwwwwwpwwwwwwwwwwwww
  443. wwwwwwwwwwwwp
  444. wwwwwwwwwwww
  445. wwwwwwwwwwwwpwwwwwwwwwwwww
  446. wwwwwwwwwwwwp
  447. wwwwwwwwwwww
  448. wwwwwwwwwwwwpwwwwwwwwwwwww
  449. wwwwwwwwwwwwp
  450. wwwwwwwwwwww
  451. wwwwwwwwwwwwpwwwwwwwwwwwww
  452. wwwwwwwwwwwwp
  453. wwwwwwwwwwww
  454. wwwwwwwwwwwwpwwwwwwwwwwwww
  455. wwwwwwwwwwwwp
  456. wwwwwwwwwwww
  457. wwwwwwwwwwwwpwwwwwwwwwwwww
  458. wwwwwwwwwwwwp
  459. wwwwwwwwwwww
  460. wwwwwwwp
  461. wwwwwwp
  462. wwwwwwwp
  463. wwwwwwp
  464. wwwwwwwp
  465. wwwwwwp
  466. wwwwwww
  467. wwwwwww
  468. wwwwwwwp
  469. wwwwwww
  470. wwwwwww
  471. wwwwwwp
  472. wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
  473. wwwwwwwp
  474. wwwwwwp
  475. wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
  476. wwwwwwwwp
  477. wwwwwwwwp
  478. wwwwwwx
  479. wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwp
  480. wwwwwwwwwww
  481. wwwwwwwwwwpwwwwwwwwwww
  482. wwwwwwwwwwp
  483. wwwwwwwwww
  484. wwwwwwwwwwp
  485. wwwwwwwwww
  486. wwwwwwwwwwp
  487. wwwwwww
  488. wwwwwww
  489. wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
  490. wwwwwwwwwwpwwwwwwwwwww
  491. wwwwwwwwwww
  492. wwwwwwwwwwp
  493. wwwwwwwwwwpwwwwwwwwwww
  494. wwwwwwwwwww
  495. wwwwwwwwwwpwwwwwwwwwww
  496. wwwwwwwwwww
  497. wwwwwwwwwwpwwwwwwwwwww
  498. wwwwwwwwwwpwwwwwwwwwww
  499. wwwwwwwwwwp
  500. wwwwwwwwww
  501. wwwwwwwwww
  502. wwwwwwwwwwp
  503. wwwwwwwwwwp
  504. wwwwwwwwww
  505. wwwwwwwwww
  506. wwwwwwwwwwp
  507. wwwwwwwwww
  508. wwwwwwwwww
  509. wwwwwwwwwwp
  510. wwwwwwwwww
  511. wwwwwwwwwwp
  512. wwwwwwwwww
  513. wwwwp
  514. wwwwww
  515. wwwwwwwwwwwww
  516. wwwwwww
  517. wwwwwww
  518. wwwwwww
  519. wwwwwww
  520. wwwwwww
  521. wwwwwww
  522. wwwwwwwww
  523. wwwwwwwww
  524. wwwwwwwww
  525. wwwwwwwww
  526. wwwwwwwww
  527. wwwwwwwww
  528. wwwwwwwww
  529. wwwwwwwww
  530. wwwwwwwww
  531. wwwwwwwww
  532. wwwwwwwww
  533. wwwwwwwww
  534. wwwwwwwww
  535. wwwwwwwww
  536. wwwwwwwww
  537. wwwwwwwww
  538. wwwwwwwww
  539. wwwwwwwww
  540. wwwwwwwww
  541. wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwp
  542. wwwwwwwp
  543. wwwwwww
  544. wwwwwwp
  545. wwwwwww
  546. wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
  547. wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwx
  548. wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
  549. wwwwwwwp
  550. wwwwwwwp
  551. wwwwwwp
  552. wwwwwwp
  553. wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
  554. wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
  555. wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwp
  556. wwwwwwwwwwpwwwwwwwwwww
  557. wwwwwwwwwww
  558. wwwwwwwwwwp
  559. wwwwwwwwwwpwwwwwwwwwww
  560. wwwwwwwwwww
  561. wwwwwwwwwwpwwwwwwwwwww
  562. wwwwwwwwwww
  563. wwwwwwwwwwpwwwwwwwwwww
  564. wwwwwwwwwwpwwwwwwwwwww
  565. wwwwwwwwwwp
  566. wwwwwwwwww
  567. wwwwwwwwww
  568. wwwwwwwwwwp
  569. wwwwwwwwwwp
  570. wwwwwwwwww
  571. wwwwwwwwww
  572. wwwwwwwwwwp
  573. wwwwwwwwww
  574. wwwwwwwwww
  575. wwwwwwwwwwp
  576. wwwwwwwwww
  577. wwwwwwwwwwp
  578. wwwwwwwwww
  579. wwwwp
  580. wwwwww
  581. wwwwwwwwwwwwwwwwwwwwwwwwwwwww
  582. wwwwwwwwwwwwwwwwwwwwwwwwwwwww
  583. Clicking the Options button 
  584. opens a menu of different 
  585. ways to get around in the 
  586. tutorial, as shown inA
  587. the diagram at right.
  588. Summary:
  589. BVisual Basic applications, which are event-driven, allow users to 
  590. @control how they enter information.  Visual Basic makes it easy 
  591. Bto create standard applications in the Microsoft Windows operating@
  592. system.
  593. Action
  594. *Button is selected with mouse or keyboard.
  595. !Control is dropped on the button.
  596. #Control is dragged over the button.
  597. Button gets the focus.
  598. *Key is pressed while button has the focus.
  599. ,Key is pressed, and ASCII value is returned.
  600. +Key is released while button has the focus.@
  601. Button loses the focus.T
  602. The event name is the
  603. action that triggers theA
  604. code in the event procedure.\
  605.  cmdChange_Click ( )
  606.     ChangeSignal   
  607. ' Call the procedureA
  608. End Sub
  609. :In a traditional programming environment, users must enter
  610. Ainformation in an order determined by the application programmer.@BFor example, they have to answer the following questions in order.
  611. EA Visual Basic application's interface is made up of objects -- forms
  612. ?and controls.  Each object recognizes actions, such as the user
  613. ?clicking a button, opening a form, or typing in a field.  These
  614. actions are referred to as 
  615. events@
  616. <By clicking the OK button, you've run the code in this event@Bprocedure.  Every time the button is clicked, the code runs again.
  617. DWhen an event occurs in your application, Visual Basic automatically
  618. Brecognizes the event and runs the code that you've written for it.
  619. This code is called an 
  620. event procedure@
  621. >Each form and control in Visual Basic responds to a predefined
  622. <set of events.  For example, a command button recognizes the@
  623. following events.
  624. AFor example, you might want to check the contents of the text box
  625. $when the user chooses the OK button.
  626. @<Clicking the OK button triggers the cmdOKButton_Click event.
  627.  cmdOKButton_Click ( )
  628.  txtState.Text = ''WA'' 
  629.           OrderFormWA.Show
  630.           
  631. OrderFormGeneral.ShowA
  632. End SubI
  633. The object name is the
  634. form or control toA
  635. which you attach code.
  636. Object8
  637. Closes the tutorial andA
  638. returns to Visual Basic.j
  639. A red arrow  
  640. points to an instruction 
  641. 'for you to follow to continue with the A    tutorial.
  642. Event procedures can also:
  643. Trigger other event procedures.
  644. Change an object's properties.
  645.  @=Call other general procedures that are not tied to any event.F
  646. )Press ENTER or click the OK button to runA
  647. the event procedure.v
  648. Event procedures can also:
  649. Trigger other event procedures.
  650. Change an object's properties.
  651. EAn event procedure runs only when the event occurs, and Visual Basic 
  652. Oremains idle until that happens.  You can see how this works for the OK button.
  653. Click the OK button or press 
  654. ENTER@
  655. Event
  656. Click
  657. DragDrop
  658. DragOver
  659. GotFocus
  660. KeyDown
  661. KeyPress
  662. KeyUp@    LostFocus
  663. Personnel Information
  664. Address:
  665. Name:
  666. City:
  667. State:
  668. Project1    
  669. Enter your name >  Joe Smith
  670. #Enter your address > 555 Cedar LaneA
  671. Enter your city >_
  672. A    Joe Smith
  673. 98555
  674. Redmond
  675. Controls 
  676. TextA
  677.  = '' '' Then
  678. Sub cmdOKButton_Click ( )
  679.      If txtName.Text = '' '' Then
  680. $         MsgBox ''Enter your name.''
  681.     End IfB
  682. End Sub
  683. Sub cmdOKButton_Click ( )
  684.      If txtName.Text = '' '' Then
  685. $         MsgBox ''Enter your name.''
  686. End IfA
  687. End Sub
  688. Sub cmdOKButton_Click ( )
  689.      If txtName.Text = '' '' Then
  690.              
  691. MsgBox
  692.  ''Enter your name.''
  693.     End IfA
  694. End Sub
  695. Sub cmdOKButton_Click ( )
  696.  txtName.Text 
  697.  '' '' 
  698. $         MsgBox ''Enter your name.''
  699.     End IfA
  700. End Sub
  701. =You need to write code only for the events that you want your
  702. application to respond to.
  703. DTo determine which events to write code for, you need to think about@?what the user will do, and how you want the program to respond.
  704. >Event procedure names combine the control name, an underscore,
  705. 8and the event name.  So the event procedure name for the
  706. "cmdOKButton's Click event would be
  707. cmdOKButton_Click.
  708. AAn event procedure name is made up of an object name and an event
  709. Gname.  The object name for all forms is Form.  For controls, the object
  710. @name is the control's Name property.   There can be one or more @!statements in an event procedure.
  711. "This lesson will introduce you to:
  712. Event-driven programming
  713. Event procedures
  714.   o @
  715. Syntax for eventsw
  716. -Click the Next button ( > ) to continue.  To 
  717. *return to the Menu or exit Learning VisualA
  718. Basic, click Options.
  719. Opens this window.-
  720. Jumps to the SummaryA
  721. for that lesson.
  722. Returns to the Menu.!
  723. Closes the Options A
  724. menu.%
  725. Returns to theA
  726. previous step.
  727. OptionsX
  728. +When you're done reading the Instructions, A$click the Close Instructions button.O
  729. Event procedures can also:
  730. Trigger other event procedures.
  731. This lesson covered:
  732. Event-driven programming
  733. Event procedures
  734. Syntax for events
  735. %For more information on event-driven 
  736. programming, see the lesson
  737. -''Debugging Your Application'' or Chapter 6, 
  738. $''Programming Fundamentals,'' in theC
  739. Programmer's Guide.
  740.  chkBold_Click ( )
  741.   If 
  742. chkBold.Value = 1 
  743. Then 
  744.      
  745.         txtDisplay.FontBold = 
  746. End IfA
  747. End Subd
  748. &Click the Menu button to return to the
  749. +Learning Visual Basic Menu.  To exit, clickA
  750. Options.B
  751.  cmdDelete_Click ( )
  752.     mnuDelete_ClickA
  753. End Sub
  754. :Visual Basic is a programming system that you use to write
  755. event-driven applications
  756. (.  Programming in response to particular
  757. Fevents, such as a key press or a mouse click, makes it easy to create @;applications that are visually appealing and simple to use.
  758. Period
  759. cmdOKButtonv
  760.  If txtName.Text = '' '' Then
  761. $         MsgBox ''Enter your name.''
  762.     End IfA
  763. End Sub
  764. Click B
  765. txtName
  766. Sub cmdOKButton_Click ( )
  767.     If 
  768. $         MsgBox ''Enter your name.''
  769.     End IfA
  770. End Sub5
  771. A.How to Use the Learning Visual Basic Tutorial 5
  772. A.How to Use the Learning Visual Basic Tutorial 
  773. Sub cmdOKButton_Click ( )
  774.     If 
  775. txtName.Text
  776.  = '' '' Then
  777. $         MsgBox ''Enter your name.''
  778.     End IfA
  779. End Sub
  780.  cmdOKButton_Click 
  781.      If txtName.Text = '' '' Then
  782. $         MsgBox ''Enter your name.''
  783.     End IfC
  784. End Sub
  785.  cmdOKButton_Click 
  786.  txtName.Text 
  787.  '' '' 
  788.              
  789. MsgBox
  790.  ''Enter your name.''
  791. End IfA
  792. End Sub
  793. ;You refer to a control and its properties in code using the
  794. Eobject.property notation.  For example, to refer to text displayed in@,a text box, the syntax would look like this:
  795. Enter your name.
  796. Property"
  797. cmdOKButton_Click B
  798. Statements are the
  799. code you want to runA
  800. when the event occurs.
  801. Name;
  802. To go forward in a lesson,A
  803. click the Next button.  <
  804. To go backward in a lesson,A
  805. click the Back button.  $
  806. Writing Event-Driven Programs
  807. Underscore
  808. Event_
  809. ,To return to the Learning Visual Basic Menu,A*press the SPACEBAR.  To exit, press ALT+O.
  810. )Press the PAGE DOWN key to continue with 
  811. (this lesson.  To choose another part of A.Learning Visual Basic or to exit, press ALT+O.
  812. Form    &Options
  813. &Back
  814. &Instructions
  815. &Menu
  816.     &Summary
  817. E&xit Tutorial
  818. Cancel: Esc
  819. &Close Instructions
  820. Summary:
  821. 2. Set properties
  822. You set the properties of a
  823. !control in the Properties window.
  824. #When you select a form or control, 
  825. "its properties and their settings 
  826.  are displayed in the Properties @
  827. window.
  828. Form1
  829. Creating an Application
  830. Every new project contains one
  831. form.  You can add as many
  832. additional forms as your
  833. application needs.
  834. The Temperature Conversion
  835. application requires only one@
  836. form.
  837. Form1
  838. Celsius:
  839. Fahrenheit:+
  840. Code that controls A
  841. the application
  842. KeyPressh
  843. *Sub txtCels_KeyPress (KeyAscii As Integer)
  844. ,    txtFahr.Text = 9/5 * (txtCels.Text) + 32A
  845. End Sub
  846. project 
  847.     includes:
  848. Forms -- backgrounds,  
  849. windows, and dialog boxes.
  850. Controls -- graphical objects 
  851. placed on forms.
  852. procedures and 
  853.     @
  854. declarations.
  855. Proc:
  856. Object:6
  857. Text boxes for 
  858. entering and A
  859. displaying text
  860. A form
  861. $There are three steps to creating an
  862. application:
  863. Create the interface.
  864. Set properties.
  865. Write code.
  866. 3. Write code
  867. To make the application respond
  868. "to the user's actions, we'll write
  869. event procedures for the text 
  870. boxes. 
  871. These event procedures are @
  872. triggered by a KeyPress event.
  873. This form is the background of
  874. the application.
  875. We can change the size and
  876. location of the form to fit the@
  877. application's design.{
  878. .Type a number in the text box, and then press 
  879. ,ENTER.  To continue with the tutorial, clickA
  880. the Next ( > ) button.
  881.  Next, we'll select the tools we 
  882. need from the Toolbox to draw
  883. !the controls we want on the form.
  884. In this application, text boxes
  885. accept user input and display
  886. text.@
  887.  We'll create two text boxes, one
  888.  for Fahrenheit temperatures and 
  889. one for Celsius temperatures.
  890. When the user enters a
  891. temperature in one of the text
  892. "boxes, the equivalent temperature @#is displayed in the other text box.`
  893. The pieces of the application
  894. are now in place.  To make it @
  895. work, we need to add the code.b
  896. Once you save a project, you
  897. can go back and change its
  898. appearance or operation at any@
  899. time.i
  900.  To describe the contents of each
  901. text box, we'll use labels.
  902. Labels can't be changed by the@
  903. user.
  904. #We'll use the following formulas to
  905. convert the temperatures:
  906.      Cels = (Fahr - 32) * 5/9
  907.      Fahr = (Cels * 9/5) + 32
  908. "Next, we'll enter the code for the@
  909. event procedure.
  910. The Procedure list box contains
  911. !a list of events for the control.
  912. "Selecting the KeyPress event from 
  913. $the Procedure list box displays the 
  914. !template for the event procedure @
  915. we want to write.
  916. Now, we'll change the Name 
  917. property of the other text
  918. box to txtFahr and the Caption 
  919. property of its label to @
  920. Fahrenheit.E
  921.  Now we'll attach a similar event@ procedure to the other text box.
  922. To try out the application:
  923. Type values in the text box,
  924.       and press 
  925. ENTER
  926.  to convert @
  927.       the temperature.
  928. When you finish working on your
  929.  application, you'll want to save
  930. the project.
  931. Choosing Save Project from the 
  932. File menu prompts you to assign@
  933. a name to the project.#
  934. @ The application is now complete.
  935.  You can test your application by
  936.  choosing Start from the Run menu
  937. or clicking the Start button ( 
  938. the toolbar.
  939. You can also use the debugging 
  940. tools to help locate and fix @
  941. problems in your application.
  942. (This lesson demonstrated how to create a
  943. simple application:
  944.    1.  Create the interface.
  945.    2.  Set properties.
  946.    3.  Write code.
  947. /The lessons that follow explain the parts of a @(Visual Basic application in more detail.
  948. Enter a temperature:M
  949. :As you run your application, you might also think of ways @
  950. to improve it.
  951. %Provide a graphical way to enter and A+display the temperatures using scroll bars.R
  952. %Add a command button that clears the A$temperatures from both text boxes.  
  953.  When your application is exactly
  954. the way you want it, you can
  955.  make it into an executable file.
  956. !This allows you, and other users,
  957. #to run the application outside the @
  958. Visual Basic environment.
  959. Celsius:
  960. Fahrenheit:
  961. When the user types a
  962. temperature in one of the text
  963. boxes and presses 
  964. ENTER
  965. , the
  966. !code updates the contents of the @
  967. other text box.w
  968. -Click the Next button ( > ) to continue.  To 
  969. *return to the Menu or exit Learning VisualA
  970. Basic, click Options.j
  971. ,Click the Menu button ( > ) to return to the
  972. +Learning Visual Basic Menu.  To exit, clickA
  973. Options.
  974. Opens this window.-
  975. Jumps to the SummaryA
  976. for that lesson.
  977. Returns to the Menu.!
  978. Closes the Options A
  979. menu.%
  980. Returns to theA
  981. previous step.
  982. OptionsX
  983. +When you're done reading the Instructions, A$click the Close Instructions button.h
  984. Assist the user by providing 
  985. &instructions and checking for invalid A
  986. entries in the text boxes.
  987. CThis lesson demonstrates how to build a Visual Basic application.  
  988. @EThe application converts temperatures between Fahrenheit and Celsius.
  989. 1.  Create the interface
  990. To create an application, you 
  991. !first need to open a new project.
  992. You open a project by choosing
  993. the New Project command from@
  994. the File menu.
  995. The Caption property specifies
  996. !the text that is displayed in the
  997. #control.  We'll change the label's @
  998. Caption property to Celsius.5
  999. A.How to Use the Learning Visual Basic Tutorial 5
  1000. A.How to Use the Learning Visual Basic Tutorial k
  1001. To create an executable file
  1002. from your project, you use the
  1003. Make EXE File command from@
  1004. the File menu.
  1005. %To create a control, select the tool 
  1006. from the Toolbox, and then hold
  1007.  down the left mouse button while
  1008. !dragging out an area on the form.
  1009.  You can create a control in the 
  1010.  default size by double-clicking 
  1011. !the tool or selecting a tool and 
  1012.     pressing 
  1013. ENTER@
  1014. Labels
  1015. )You can't go back from this point in the 
  1016. %lesson.  To review the lesson, chooseA&Creating an Application from the Menu.;
  1017. To go forward in a lesson,A
  1018. click the Next button.  <
  1019. To go backward in a lesson,A
  1020. click the Back button.  
  1021. Clicking the Options button 
  1022. opens a menu of different 
  1023. ways to get around in the 
  1024. tutorial, as shown inA
  1025. the diagram at right.8
  1026. Closes the tutorial andA
  1027. returns to Visual Basic.j
  1028. A red arrow  
  1029. points to an instruction 
  1030. 'for you to follow to continue with the A    tutorial.E
  1031. @BThe Temperature Conversion application consists of these elements:_
  1032. ,To return to the Learning Visual Basic Menu,A*press the SPACEBAR.  To exit, press ALT+O.
  1033. )Press the PAGE DOWN key to continue with 
  1034. (this lesson.  To choose another part of A.Learning Visual Basic or to exit, press ALT+O.~
  1035. You use the Name property to 
  1036. %refer to a control in code.  In this 
  1037. case, we'll make txtCels the @
  1038. name of this text box.
  1039.  When you double-click a control,
  1040. the focus shifts to the Code 
  1041. window.  The code template for 
  1042. the selected control's default 
  1043. event procedure is displayed.
  1044.  The name of the control appears @
  1045. in the Object list box.    &Options
  1046. &Menu
  1047. Update
  1048. txtCels
  1049. Celsius:
  1050. txtFahr
  1051. Endif
  1052. Fahrenheit:
  1053. &Back
  1054. &Instructions
  1055.     &Summary
  1056. E&xit Tutorial
  1057. Cancel: Esc
  1058. 'txtCels.Text = Val(txtFahr.Text-32)*5/9.If (KeyAscii=13)Then ' keyascii 13 = Enter key-txtFahr.Text = 9 / 5 * Val(txtCels.Text) + 32,
  1059. &Close Instructions
  1060. z    [    z    
  1061. n    ,    -
  1062. wwwwwww
  1063. wwwwwww
  1064. wwwwwww
  1065. wwwwwww
  1066. One minute....
  1067. ...files are being loaded.
  1068.  After you enter the caption and 
  1069. name, you can click the Next 
  1070. button or press 
  1071. ENTER
  1072.  to create 
  1073. the File menu control.
  1074. "The highlight then moves to a new 
  1075. #line, and the text boxes are reset 
  1076. to accept the next caption and @
  1077. name.
  1078. ountryi
  1079. =Menus consist of menu titles, menu items, and separator bars.@'Every part of a menu is a menu control.
  1080. Separator bar
  1081. A    Menu item
  1082. ountry
  1083. Sweden
  1084. Menu title
  1085. Population
  1086. Income per Capita
  1087. $A menu is a control, like a text box
  1088. !or a command button.  Like other 
  1089. !controls, a menu has a predefined@
  1090. set of properties and events.
  1091. To distinguish menu items from
  1092.  menu titles, you indent the menu
  1093. !items in the lower portion of the
  1094. Menu Design window.
  1095.  To indent a menu item, select it
  1096. and then click the right arrow @
  1097. button.
  1098. Create the File menu
  1099. "The text you enter in the Caption 
  1100. text box defines the menu name.
  1101. !This is the text that appears on 
  1102. the menu bar.@
  1103.  The text in the Name box defines
  1104. the menu's Name property.  This
  1105. !is used to refer to the File menu@
  1106. in code.
  1107. In addition, you can set other
  1108. menu properties in the Menu
  1109. Design window.
  1110. After you have created a menu,
  1111. you can change its property
  1112. "settings in either the Menu Design@ window or the Properties window.
  1113. specifies a menu title, such 
  1114. "   as File or Edit, or an item on 
  1115.    a menu, such as Open or Cut.
  1116.  the name used to refer to the 
  1117.    menu control in code.
  1118. a numeric value that uniquely 
  1119. %   identifies the menu control if it A
  1120.    is part of a control array.q
  1121. .You use the Menu Design window to create menu 
  1122. "controls and set their properties:
  1123. Caption@
  1124. .You use the Menu Design window to create menu 
  1125. "controls and set their properties:
  1126. Caption
  1127. Index
  1128. ext Country
  1129. The File menu now consists of
  1130. one command -- Exit.
  1131.  Next, we'll add the second menu 
  1132. !to the menu bar -- Country -- and
  1133. a command to the Country @
  1134. menu -- Next Country. 
  1135. ind...
  1136. Inserting an ampersand (&) 
  1137. before a letter gives the user 
  1138. keyboard access to the menu.
  1139.  At run time, this letter will be
  1140. underlined.
  1141. "For example, in this menu the user
  1142. could select the File menu by 
  1143.     pressing A
  1144. ALT+F.
  1145. Adding Menus
  1146. Opens this window.-
  1147. Jumps to the SummaryA
  1148. for that lesson.
  1149. Returns to the Menu.!
  1150. Closes the Options A
  1151. menu.%
  1152. Returns to theA
  1153. previous step.
  1154. OptionsX
  1155. +When you're done reading the Instructions, A$click the Close Instructions button.w
  1156. -Click the Next button ( > ) to continue.  To 
  1157. *return to the Menu or exit Learning VisualA
  1158. Basic, click Options.
  1159. Open the Menu Design window
  1160. You use the Menu Design window 
  1161. to create menus for your form.
  1162.  Switch to the form to which you 
  1163. want to add a menu, and then @
  1164. open the Menu Design window. 
  1165. GThis lesson will demonstrate how to create menus in Visual Basic using 
  1166. 'the Countries of the World application.
  1167. DThis application has two menus on its menu bar:  File and Country.  @CThe commands on the menus remain hidden until the menu is selected.
  1168. revious Country
  1169. eA    w Country5
  1170. A.How to Use the Learning Visual Basic Tutorial 
  1171. This lesson covers:
  1172. The Menu Design window
  1173. Menus and menu commands
  1174. Menu design guidelines5
  1175. A.How to Use the Learning Visual Basic Tutorial 
  1176. Add the Exit menu command
  1177. To add the Exit command to the
  1178. File menu, we'll enter E&xit in
  1179. the Caption box.
  1180. In the Name box, we'll enter
  1181.  mnuFileExit to refer to the Exit@
  1182. command in code.
  1183. (The example files needed for this lesson
  1184. )cannot be found.  To run this lesson, youA(need to reinstall Learning Visual Basic.;
  1185. To go forward in a lesson,A
  1186. click the Next button.  <
  1187. To go backward in a lesson,A
  1188. click the Back button.  
  1189. Clicking the Options button 
  1190. opens a menu of different 
  1191. ways to get around in the 
  1192. tutorial, as shown inA
  1193. the diagram at right.8
  1194. Closes the tutorial andA
  1195. returns to Visual Basic.j
  1196. A red arrow  
  1197. points to an instruction 
  1198. 'for you to follow to continue with the A    tutorial.
  1199. )Press the PAGE DOWN key to continue with 
  1200. (this lesson.  To choose another part of A.Learning Visual Basic or to exit, press ALT+O.
  1201. .You use the Menu Design window to create menu 
  1202. "controls and set their properties:
  1203. Caption
  1204. specifies a menu title, such 
  1205. "   as File or Edit, or an item on 
  1206.    a menu, such as Open or Cut.
  1207. the name used to refer to the A
  1208.    menu control in code.w
  1209. specifies a menu title, such 
  1210. "   as File or Edit, or an item on A
  1211.    a menu, such as Open or Cut.
  1212. You open the Menu Design
  1213. window by choosing the Menu
  1214. Design command from the 
  1215. Window menu or choosing the 
  1216. Menu Design button from the@
  1217. toolbar.    &Options
  1218. &File
  1219. mnuFile
  1220. mnuFileExit
  1221. &Back
  1222. &Instructions
  1223. &Menu
  1224.     &Summary
  1225. E&xit Tutorial
  1226. Cancel: Esc
  1227. E&xit
  1228. sweden.frm
  1229. Return to &Menu
  1230. E&xit Learning VB
  1231. country.mak,
  1232. &Close Instructions
  1233. Summary:
  1234. Select mnuFileExit from the 
  1235. Object box
  1236. We entered mnuFileExit as the 
  1237. Exit command's Name property.
  1238. The Name property is used@
  1239. to refer to a control in code.
  1240. Write the code
  1241. We'll write code to make the
  1242.  application respond to the Exit 
  1243. command.  The code goes
  1244. between the Sub and End Sub 
  1245. statements in the Code window.@
  1246. The code we entered ends the @#Countries of the World application.
  1247. Separator A
  1248. New...
  1249. Open...
  1250. Close the Menu Design window
  1251. When you close the Menu
  1252. Design window, the menus are
  1253. automatically displayed on the@
  1254. form.
  1255. BWhen creating menus, follow these standard menu design guidelines:
  1256. )Group related commands on a menu in a way
  1257. 2that will make sense to users of your application.
  1258. +For example, users familiar with Microsoft 
  1259. *Windows may expect to find the New, Open, 
  1260. /and Close commands together on the File menu.  
  1261. ,Look at existing Windows-based applications 
  1262. for examples.
  1263. *On long menus, separate groups of related 
  1264. *commands with a separator bar.  Separator 
  1265. .bars are created by using a single hyphen (-) 
  1266.    @-in the Caption box of the Menu Design window.
  1267. Adding Menus
  1268. Opens this window.-
  1269. Jumps to the SummaryA
  1270. for that lesson.
  1271. Returns to the Menu.!
  1272. Closes the Options A
  1273. menu.%
  1274. Returns to theA
  1275. previous step.
  1276. OptionsX
  1277. +When you're done reading the Instructions, A$click the Close Instructions button.w
  1278. -Click the Next button ( > ) to continue.  To 
  1279. *return to the Menu or exit Learning VisualA
  1280. Basic, click Options.d
  1281. &Click the Menu button to return to the
  1282. +Learning Visual Basic Menu.  To exit, clickA
  1283. Options.
  1284. When the user clicks a menu 
  1285. "title, Visual Basic automatically 
  1286. displays its menu.
  1287. To define how each menu
  1288. command responds to a Click
  1289. event, you write an event@
  1290. procedure for each command.
  1291. Close
  1292. Save As...5
  1293. A.How to Use the Learning Visual Basic Tutorial 5
  1294. A.How to Use the Learning Visual Basic Tutorial 
  1295. Menu commands respond only 
  1296. #to Click events.  If a user selects
  1297.  a menu item when the application
  1298. !is running, the associated Click @
  1299. event procedure is executed.;
  1300. To go forward in a lesson,A
  1301. click the Next button.  <
  1302. To go backward in a lesson,A
  1303. click the Back button.  t
  1304. )You can't go back from this point in the 
  1305. %lesson.  To review the lesson, chooseA
  1306. Adding Menus from the Menu.
  1307. Clicking the Options button 
  1308. opens a menu of different 
  1309. ways to get around in the 
  1310. tutorial, as shown inA
  1311. the diagram at right.8
  1312. Closes the tutorial andA
  1313. returns to Visual Basic.j
  1314. A red arrow  
  1315. points to an instruction 
  1316. 'for you to follow to continue with the A    tutorial.
  1317. Open the Code window
  1318. "You write event procedures in the 
  1319. Code window.
  1320. To open the Code window for a
  1321. form, choose View Code from the
  1322. Code menu, or press
  1323. %This lesson showed you how to create 
  1324. )menus for your Visual Basic applications 
  1325. using the Menu Design window.  
  1326. 'For more information on creating menus,
  1327. &see Chapter 4, ''Menus and Dialogs,'' 
  1328. in theA
  1329.  Programmer's Guide._
  1330. ,To return to the Learning Visual Basic Menu,A*press the SPACEBAR.  To exit, press ALT+O.
  1331. )Press the PAGE DOWN key to continue with 
  1332. (this lesson.  To choose another part of A.Learning Visual Basic or to exit, press ALT+O.    &Options
  1333. &Country
  1334. mnuCountry
  1335. &Next Country
  1336. mnuCountryNextCountry
  1337. &Back
  1338. &Instructions
  1339. &Menu
  1340.     &Summary
  1341. E&xit Tutorial
  1342. Cancel: Esc
  1343. &Close Instructions
  1344. The Properties
  1345. list displays all 
  1346. the available
  1347. properties for
  1348. the selectedA
  1349. form or control.
  1350. Command ButtonG
  1351. The Object box
  1352. shows the currently 
  1353. selected form orA
  1354. control.
  1355. Form1
  1356. Form1 B
  1357. AutoRedraw
  1358. A    BackColor
  1359. BorderStyle
  1360. Form1
  1361. ClipControls
  1362. ControlBox
  1363. DrawMode
  1364. A    DrawStyle
  1365. A    DrawWidth
  1366. Enabled
  1367. False
  1368. &80000005&
  1369. 2 - Sizable
  1370. Caption
  1371. Payment Amount:
  1372. &The drive list box finds and switches 
  1373. $among valid drives at run time.  It 
  1374. +displays a list of the user's valid drives.
  1375. *You can use the drive list box control as A)part of a dialog box used to open a file.
  1376. You draw graphical objects
  1377. called 
  1378.     controls 
  1379. on a form to
  1380. accept user input or display
  1381. output.
  1382. You draw a control by selecting@"one of the tools from the Toolbox.
  1383. Pointer
  1384. *A text box is an area in which text can be
  1385. 'entered by the user or displayed by the
  1386. (application.  A text box can contain one
  1387.  or more lines of text and can be
  1388. scrollable.
  1389. !For example, in a security-system
  1390. (application, you might use a text box toA
  1391. prompt a user for a password.
  1392. Label
  1393. +The file list box displays all the files in
  1394. %a given directory.  You can display a
  1395. +list of files based on file attributes, and
  1396. &users can select a file from the list.
  1397. (You can use a file list box as part of aA
  1398. dialog box used to open a file.
  1399. File List Box
  1400. 'A timer can be used to cause actions to
  1401. &occur at regular intervals while your 
  1402. application is running.
  1403. $For example, you can use a timer to A+update a clock display in your application.
  1404. Directory List Box
  1405. %The shape control displays a circle, 
  1406.  square, oval, rectangle, rounded
  1407. %rectangle, or rounded square.  Unlike
  1408. &graphics methods, the shape control is
  1409. visible at design time.
  1410. 'For example, you can use shape and line
  1411. *controls to create a graphic of a building
  1412. layout.A
  1413. Drive List Box
  1414. (A picture box control is used to display
  1415. *graphics on your form and to draw graphics
  1416. +in code.  It can display a bitmap, icon, or
  1417. +metafile.  As much of the picture as can be
  1418. .displayed within the picture rectangle will be
  1419. shown.
  1420. )You can create animation in a picture box
  1421. +by manipulating the graphics properties andA
  1422. methods.
  1423. Timer
  1424. %A line control displays a horizontal,
  1425. (vertical, or diagonal line.  You can use
  1426. %line controls to draw lines on forms.
  1427. )Unlike the Line method, line controls are
  1428. visible at design time.
  1429. *You can use lines to display callouts on aA*graphic or to divide a form into sections.
  1430. Vertical Scroll Bars
  1431. Horizontal Scroll Bars
  1432. .An option button is used to select an option, 
  1433. %usually from among a group of option 
  1434. -buttons.  When an option button is selected, 
  1435. )the button has a black center.  Unlike a 
  1436. &group of check boxes, only one option 
  1437. $button can be selected from a group.
  1438. ,For example, you might use an option button 
  1439. (group to indicate the method of payment A-(cash, check, or credit card) for an invoice.
  1440. Picture Box
  1441. A    Combo Box
  1442. -Horizontal scroll bars allow the user to move
  1443. *horizontally within lists or through large
  1444. ,amounts of information.  They also provide a
  1445. 'graphical way of displaying and setting
  1446. values.
  1447. 'For example, you could use a horizontal
  1448. 0scroll bar to set the volume for an application 
  1449. *that plays music or to show how much time 
  1450. has elapsed.A
  1451. Option Button
  1452. A    Check Box
  1453. Option Button
  1454. Frame
  1455. Image
  1456. Text Box
  1457. Clicking the Options button 
  1458. opens a menu of different 
  1459. ways to get around in the 
  1460. tutorial, as shown inA
  1461. the diagram at right.
  1462. &A combo box combines a text box and a 
  1463. +list box.  The user can either type in the 
  1464. +text box or select items from the list box.
  1465. %There are three types of combo boxes:
  1466. $drop-down combo boxes, simple combo 
  1467.  boxes, and drop-down list boxes.
  1468. %You can use drop-down combo boxes andA'list boxes to save room on your forms. 
  1469. Image
  1470. Picture Box
  1471. List Box
  1472. Shape
  1473. $A label displays text that cannot be
  1474. %changed by the user.  The text can be
  1475. 'changed by the application at run time,
  1476. !however, in response to an event.
  1477. *You can use a label to display information
  1478. *for the user.  For example, you could show
  1479. *the time or the progress of a file-copyingA
  1480. operation.
  1481. 13 - Copy Pen
  1482. This option button group will
  1483. !consist of a frame and two option
  1484. buttons.
  1485. To put an object inside another
  1486. object, you must create the
  1487. container first, and then place@
  1488. the object inside it.
  1489. A    0 - Solid
  1490. Properties
  1491.  Each tool in the Toolbox creates
  1492. a unique control.  Each control
  1493. has built-in capabilities.
  1494.  For example, Visual Basic allows
  1495. #users to cut and paste text in text
  1496. boxes without requiring you to @
  1497. write any code.
  1498. In earlier lessons, you've seen
  1499. how to add a control to a form.
  1500. Here, we've designed a form
  1501.  with one label and one text box.
  1502.  Next, we'll add an option button
  1503. group to the form to let users@!indicate their method of payment.
  1504. ,An image control is a graphical control that
  1505. 0can display a picture.  It is like a picture box
  1506. *control but uses fewer resources, repaints
  1507. %faster, and supports only some of the
  1508. +picture box properties, methods and events.
  1509. &For example, you can place a bitmap of
  1510. )your company logo in an image control and
  1511. ,display text about the company when the userA
  1512. clicks it./
  1513. One minute....
  1514. ...files are being loaded.
  1515. Command Button
  1516. Directory List Box
  1517. A    Check Box4
  1518. !Click the control in the Toolbox.B
  1519. A    Combo Box
  1520.  A frame provides a graphical and
  1521. *functional grouping for controls.  Objects
  1522. $are put into frames to separate them
  1523. visually from other controls.
  1524. 'You can place option buttons in a frameA!to create an option button group.
  1525. Drive List Box
  1526. File List Box
  1527. Frame
  1528. Horizontal Scroll Bars
  1529. *A list box contains a scrollable list from
  1530. %which the user can select one or more
  1531. items.
  1532. &For example, you can display a list of
  1533. %names in a list box and have the userA
  1534. choose from the list.
  1535. Label
  1536. List Box
  1537. Pointer
  1538. Shape
  1539. Text Box
  1540. Timer
  1541. Vertical Scroll Bars
  1542. Opens this window.-
  1543. Jumps to the SummaryA
  1544. for that lesson.
  1545. Returns to the Menu.!
  1546. Closes the Options A
  1547. menu.%
  1548. Returns to theA
  1549. previous step.
  1550. OptionsX
  1551. +When you're done reading the Instructions, A$click the Close Instructions button.$
  1552. @!To learn more about each control:w
  1553. -Click the Next button ( > ) to continue.  To 
  1554. *return to the Menu or exit Learning VisualA
  1555. Basic, click Options.
  1556. #The directory list box displays the
  1557. *directories and paths of the current drive
  1558. )at run time.  You can use this control to
  1559. *display a hierarchical list of directories
  1560. #from the root to the selected path.
  1561. *You can use the directory list box as partA$of a dialog box used to open a file.
  1562. .Every form and control has a predefined set of
  1563. properties
  1564. .  These properties determine:
  1565. Appearance
  1566. Behavior
  1567. When you create a form, it is
  1568.  initially displayed in a default
  1569. location and size.  You can
  1570.  change both the location and the
  1571. #size of the form to suit the design
  1572. of your application.@
  1573. Payment MethodI
  1574. @FYou set the initial values for properties using the Properties window.J
  1575. The Settings box
  1576. contains a property
  1577. setting that you A    can edit.
  1578. Charge Information
  1579. !The pointer is used to manipulate
  1580. )existing controls on your form.  With the
  1581. 'pointer, you can select, move, and size
  1582. forms and controls.
  1583. When you select a tool from the
  1584. &Toolbox, your mouse pointer changes to
  1585. *a cross hair.  After you create a control,
  1586. &your mouse pointer changes back to the
  1587. pointer.
  1588. A.How to Use the Learning Visual Basic Tutorial 5
  1589. A.How to Use the Learning Visual Basic Tutorial 
  1590. = is a window or dialog box that you create with Visual Basic.
  1591. @FIn this lesson, we will build a form that accepts payment information.
  1592. +A check box is used for an option that can 
  1593. -be turned on and off.  When the user selects 
  1594. +the option, an X is displayed in the check 
  1595. *box.  Check boxes can be used to give the 
  1596. #user a yes/no or true/false option.
  1597. #You can use check boxes for options
  1598. *that users can select in any combination, 
  1599. $such as bold, italic, and underline A
  1600. formatting.&
  1601. Working with Forms and ControlsH
  1602. Setting properties
  1603. Creating event procedures
  1604. *The grid control displays a series of rows
  1605. +and columns.  At the intersection of a row 
  1606. ,and a column is a cell.  A cell can contain 
  1607. pictures or graphics.
  1608. (You can use a grid control to display a A
  1609. table of information.
  1610. OLE Client
  1611. OLE Client
  1612. Payment
  1613. (The example files needed for this lesson
  1614. )cannot be found.  To run this lesson, youA(need to reinstall Learning Visual Basic.
  1615. Cash/Check
  1616. Charge
  1617. A    MajorCard
  1618. Viva!
  1619. AreMax;
  1620. To go forward in a lesson,A
  1621. click the Next button.  <
  1622. To go backward in a lesson,A
  1623. click the Back button.  N
  1624. This lesson will introduce:
  1625. Forms
  1626. Adding controls
  1627. ,Vertical scroll bars allow the user to move 
  1628. )vertically within lists or through large 
  1629. +amounts of information.  They also provide 
  1630. *a graphical way of displaying and setting 
  1631. values.
  1632. +For example, you could add vertical scroll 
  1633.  bars to a temperature conversion
  1634. 'application to show temperatures risingA
  1635. and falling.8
  1636. Closes the tutorial andA
  1637. returns to Visual Basic.j
  1638. A red arrow  
  1639. points to an instruction 
  1640. 'for you to follow to continue with the A    tutorial.
  1641. )Press the PAGE DOWN key to continue with 
  1642. (this lesson.  To choose another part of A.Learning Visual Basic or to exit, press ALT+O.
  1643. --  the color, size, and name
  1644. of the form.
  1645. --  whether the user can move,
  1646. size, minimize, or maximize
  1647. --  @    the form.
  1648. &A command button carries out an action
  1649. )when the user chooses it.  Typically, the
  1650.  user chooses a command button by
  1651. clicking it or by pressing the 
  1652. SPACEBAR
  1653. when it is selected.
  1654. %OK and Cancel buttons are examples of
  1655. %command buttons.  Or you might create
  1656.  a command button that a user canA
  1657. choose to open another form.
  1658. (The common dialog custom control allows 
  1659. %you to display several commonly used 
  1660. +dialog boxes: Open, Save As, Print, Color, 
  1661.     and Font.
  1662. &When you draw a common dialog control 
  1663. ,on a form, it automatically resizes itself. 
  1664. *Like the timer control, the common dialog 
  1665. !control is invisible at run time.A
  1666. Data Access
  1667. Data Access
  1668. Common Dialog
  1669. Common Dialog
  1670. +The OLE control lets you display data from 
  1671. *another Windows-based application in your 
  1672. Visual Basic application.
  1673. -At run time, you can edit the data in an OLE 
  1674. -control from within the application in which 
  1675. ,it was created. When you finish your edits, 
  1676. +you close the application, and the updated 
  1677. (data is displayed in the OLE control on 
  1678. your form.A
  1679. .The data control lets you create applications 
  1680. .to display, edit, and update information from 
  1681. +many types of existing databases.  You can 
  1682. ,use other data-aware controls with the data 
  1683. (control to display information from the 
  1684. current record in a database.
  1685. 'Visual Basic implements data access by 
  1686. 'incorporating the same database engine 
  1687. that powers Microsoft Access.A
  1688.     &Options
  1689. Payment.mak
  1690. &Back
  1691. &Instructions
  1692. &Menu
  1693.     &Summary
  1694. E&xit Tutorial
  1695. Cancel: Esc
  1696. payment.mak    form2.frm
  1697. payment.frm
  1698. Return to &Menu
  1699. E&xit Learning VB
  1700. &Close Instructions
  1701. wwwwwwwwwwwwp;)
  1702. wwwwwwwwwwwwp
  1703. @ BM6
  1704. wwwwwwwwwwwwp;)
  1705. wwwwwwwwwwwwp
  1706. @ BM6
  1707. wwwwwwwwwwwwp;)
  1708. wwwwwwwwwwwwp
  1709. @ BM6
  1710. wwwwwwwwwwwwp;)
  1711. wwwwwwwwwwwwp
  1712. @ BM6
  1713. wwwwwwwwwwwwp;)
  1714. wwwwwwwwwwwwp
  1715. @ BM6
  1716. wwwwwwwwwwwwp;)
  1717. wwwwwwwwwwwwp
  1718. @ BM6
  1719. wwwwwwwwwwwwp;)
  1720. wwwwwwwwwwwwp
  1721. @ BM6
  1722. wwwwwwwwwwwwp;)
  1723. wwwwwwwwwwwwp
  1724. @ BM6
  1725. wwwwwwwwwwwwp;)
  1726. wwwwwwwwwwwwp
  1727. @ BM6
  1728. wwwwwwwwwwwwp;)
  1729. wwwwwwwwwwwwp
  1730. @ BM6
  1731. wwwwwwwwwwwwp;)
  1732. wwwwwwwwwwwwp
  1733. @ BM6
  1734. wwwwwwwwwwwwp;)
  1735. wwwwwwwwwwwwp
  1736. @ BM6
  1737. wwwwwwwwwwwwp
  1738. wwwwwwwwwwwwp
  1739. wwwwwwwwwwwwp;)
  1740. wwwwwwwwwwwwp
  1741. @ BM6
  1742. wwwwwwwwwwwwp;)
  1743. wwwwwwwwwwwwp
  1744. @ BM6
  1745. wwwwwwwwwwwwp;)
  1746. wwwwwwwwwwwwp
  1747. @ BM6
  1748. wwwwwwwwwwwwp;)
  1749. wwwwwwwwwwwwp
  1750. @ BM6
  1751. wwwwwwwwwwwwp;)
  1752. wwwwwwwwwwwwp
  1753. @ BM6
  1754. wwwwwwwwwwwwp;)
  1755. wwwwwwwwwwwwp
  1756. @ BM6
  1757. wwwwwwwwwwwwp
  1758. wwwwwwwwwwwwpLT
  1759. wwwwwwwwwwwwp
  1760. wwwwwwwwwwwwp
  1761. fOBMb!
  1762. wwwwwwwwwwwp
  1763. wwwwwwwwwwwp
  1764. wwwwwwwwwwwpwwwwwwwwwwww
  1765. wwwwwwwwwwwp
  1766. wwwwwwwwwww
  1767. wwwwwwwwwwwpwwwwwwwwwwww
  1768. wwwwwwwwwwwp
  1769. wwwwwwwwwww
  1770. wwwwwwwwwwwpwwwwwwwwwwww
  1771. wwwwwwwwwwwp
  1772. wwwwwwwwwww
  1773. wwwwwwwwwwwpwwwwwwwwwwww
  1774. wwwwwwwwwwwp
  1775. wwwwwwwwwww
  1776. wwwwwwwwwwwpwwwwwwwwwwww
  1777. wwwwwwwwwwwp
  1778. wwwwwwwwwww
  1779. wwwwwwwwwwwpwwwwwwwwwwww
  1780. wwwwwwwwwwwp
  1781. wwwwwwwwwww
  1782. wwwwwwwwwwwpwwwwwwwwwwww
  1783. wwwwwwwwwwwp
  1784. wwwwwwwwwww
  1785. wwwwwwwwwwwpwwwwwwwwwwww
  1786. wwwwwwwwwwwp
  1787. wwwwwwwwwww
  1788. wwwwwwwwwwwpwwwwwwwwwwww
  1789. wwwwwwwwwwwp
  1790. wwwwwwwwwww
  1791. wwwwwwwwwwwpwwwwwwwwwwww
  1792. wwwwwwwwwwwp
  1793. wwwwwwwwwww
  1794. wwwwwwwwwwwpwwwwwwwwwwww
  1795. wwwwwwwwwwwp
  1796. wwwwwwwwwww
  1797. wwwwwwwwwwwwp
  1798. wwwwwwwwwwwwpLT
  1799. wwwwwwwwwwwwp
  1800. wwwwwwwwwwwwpLT
  1801. To go forward in a lesson,A
  1802. click the Next button.  
  1803. Summary:<
  1804. To go backward in a lesson,A
  1805. click the Back button.  m
  1806. Watch as we run the Payment
  1807. application and switch between
  1808. the Cash/Check and the Charge
  1809. buttons.
  1810. We now have a control array
  1811. consisting of the two option
  1812. buttons.
  1813. Now we'll add the frame and
  1814. controls for the charge@
  1815. information.
  1816. To add code to the project, you
  1817. need to open the Code window.
  1818. To view the code for a control,
  1819.  you can double-click the control
  1820.     or press 
  1821.  when the control is@
  1822. active.
  1823. The Click event for the option
  1824. #button array is loaded in the Code 
  1825. !window.  Notice that it contains 
  1826. the parameter Index 
  1827. As Integer
  1828.  Here, Index is used to refer to 
  1829.  individual items in the control 
  1830. array.
  1831. Now, watch as we add the code.
  1832.  The charge information should be
  1833. displayed only when the Charge
  1834. button is selected.
  1835. $We'll hide it by setting the Visible
  1836. property for the Charge @
  1837. Information frame to False.
  1838.  Although the Visible property is
  1839. set to False, you can still see
  1840. the frame at design time.  This
  1841. !makes it easier for you to design@    the form.
  1842. "That's all there is to creating a 
  1843. !form, adding controls, and adding
  1844. code to make your application@
  1845. respond to user input.
  1846. The two option buttons we'll
  1847. "create inside this frame will be a
  1848. control array.
  1849. A control array consists of
  1850. controls of the same type that
  1851. share a common name and@
  1852. common event procedures.w
  1853. -Click the Next button ( > ) to continue.  To 
  1854. *return to the Menu or exit Learning VisualA
  1855. Basic, click Options.
  1856. Opens this window.-
  1857. Jumps to the SummaryA
  1858. for that lesson.
  1859. Returns to the Menu.!
  1860. Closes the Options A
  1861. menu.%
  1862. Returns to theA
  1863. previous step.
  1864. OptionsX
  1865. +When you're done reading the Instructions, A$click the Close Instructions button.
  1866.  To put a control inside a frame,
  1867. you draw it on top of the frame
  1868. using the mouse, or you use the
  1869. Paste command when the frame
  1870. has the focus.
  1871. Watch as we add the two option
  1872.  buttons inside the frame and set@
  1873. their Caption properties.d
  1874. &Click the Menu button to return to the
  1875. +Learning Visual Basic Menu.  To exit, clickA
  1876. Options.
  1877. The next step is to add code to
  1878.  the form.  We want to write code
  1879. that makes the charge
  1880. information visible when the@
  1881. Charge button is selected.a
  1882. When you create a duplicate
  1883. name, Visual Basic asks if you
  1884. want to create a control array.@
  1885. A.How to Use the Learning Visual Basic Tutorial 8
  1886. Watch as we create the frame@
  1887. and set its properties.
  1888. $This lesson introduced you to forms,
  1889. *controls, properties and control arrays.  
  1890. 'The next lesson covers adding menus to 
  1891. forms.
  1892. (For more information on designing forms,
  1893. (see Chapter 2, ''Your First Visual Basic
  1894. (Application,'' and Chapter 3, ''Creating
  1895. and Using Controls,'' in theA
  1896. Programmer's Guide.5
  1897. A.How to Use the Learning Visual Basic Tutorial &
  1898. Working with Forms and Controls
  1899. )You can't go back from this point in the 
  1900. .lesson.  To review the lesson, choose Working A&with Forms and Controls from the Menu.
  1901. Clicking the Options button 
  1902. opens a menu of different 
  1903. ways to get around in the 
  1904. tutorial, as shown inA
  1905. the diagram at right.8
  1906. Closes the tutorial andA
  1907. returns to Visual Basic.j
  1908. A red arrow  
  1909. points to an instruction 
  1910. 'for you to follow to continue with the A    tutorial._
  1911. ,To return to the Learning Visual Basic Menu,A*press the SPACEBAR.  To exit, press ALT+O.
  1912. )Press the PAGE DOWN key to continue with 
  1913. (this lesson.  To choose another part of A.Learning Visual Basic or to exit, press ALT+O.
  1914. To make the option buttons a 
  1915.  control array, they need to have
  1916. the same Name property.
  1917. The Cash/Check option button
  1918.  has the name Option1.  We'll set
  1919.  the Name property of the Charge @
  1920. button to Option1.
  1921. !That's all that's needed for this
  1922. part of the code.
  1923. You can run any application
  1924. you're working on by choosing
  1925. Start from the Run menu or by
  1926. clicking the Start button ( 
  1927. ) on @
  1928. the toolbar.    &Options
  1929. Payment Method
  1930. Cash/Check
  1931. Charge
  1932. Endif
  1933. fraCharge.Visible = False
  1934. fraCharge.Visible= True
  1935. If Option1(1).Value=True then
  1936. &Back
  1937. &Instructions
  1938. &Menu
  1939.     &Summary
  1940. E&xit Tutorial
  1941. Cancel: Esc
  1942. &Close Instructions
  1943. Next Country
  1944. Summary:
  1945. dd Watch...
  1946. Opens this window.-
  1947. Jumps to the SummaryA
  1948. for that lesson.
  1949. Returns to the Menu.!
  1950. Closes the Options A
  1951. menu.
  1952. One way to avoid problems
  1953. caused by mistyped variable
  1954. names is to use the 
  1955. Option 
  1956. Explicit
  1957.  statement.
  1958. Option Explicit
  1959.  statement
  1960. requires you to declare all@
  1961. variables prior to their use.Q
  1962. :Despite your best intentions, it's common to make mistakes@
  1963. when writing code.
  1964. Logic errors
  1965. Logic errors can be harder to
  1966. #find.  When your application runs, 
  1967.  but you get results that aren't 
  1968. what you expect, you've most @
  1969. likely made an error in logic.
  1970. With your application running, 
  1971. you can see how it works.
  1972.  If Visual Basic detects an error@!in your code, it halts execution.
  1973. #Setting breakpoints to temporarily 
  1974. pause your application so you 
  1975. can step through your code may @"help you find problems with logic.
  1976. Some changes you make to 
  1977. your application, such as
  1978.  changing a constant or creating 
  1979. a new procedure, will require@
  1980. you to restart the application.
  1981. To continue running your code 
  1982. from a breakpoint, choose
  1983. the Continue command from the
  1984. Run menu, or click the Continue@
  1985. button on the toolbar.
  1986. It could be as simple as a
  1987. mistyped or undeclared variable
  1988. name, or as complicated as a
  1989. statement whose syntax is
  1990. correct but whose outcome isn't@
  1991. what you expect.
  1992. FYou can also display a list of all active procedure calls in the Calls
  1993. >dialog box.  These are procedures in the application that were
  1994. started but not completed.@
  1995. 5The Debug window allows you to examine code and watch@3expressions. It can be accessed only in break mode.R
  1996. When you start the application,
  1997. !it will run until it reaches the @
  1998. breakpoint.O
  1999. The Immediate pane allows 
  2000. you to execute one line of A
  2001. code at a time.@
  2002. The Watch pane 
  2003. shows the values of A
  2004. watch expressions.
  2005. Debug Window[Form1]j
  2006. Visual Basic provides tools to 
  2007. help you detect these problems
  2008. before you compile your @
  2009. application.
  2010.  You can then single-step through
  2011. the code by pressing 
  2012. clicking the Single Step button
  2013. on the toolbar to determine @
  2014. whether there are any problems.
  2015. When you enter code in a Code
  2016.  window, Visual Basic checks the 
  2017. "syntax as you move off a line.  If
  2018. you've made an error, Visual @ Basic displays an error message.
  2019. The cursor appears on the line
  2020. !of code containing the error, and
  2021. an error message is displayed.
  2022. You can fix the error and then
  2023. !continue running the application.
  2024. CallsV
  2025. Run-time errors
  2026. "To find run-time errors, you need @
  2027. to run your application.
  2028. Microsoft Visual Basic
  2029. nstant Watch...T
  2030. .-- mistakes that Visual Basic can detect while
  2031.  your program is running.
  2032. alls...!
  2033. ext Statement"
  2034.  Next Statement
  2035. dit Watch...
  2036. rocedure Step
  2037. iA    ngle Step
  2038. oggle Breakpoint/
  2039. One minute....
  2040. ...files are being loaded.
  2041. Clicking the Options button 
  2042. opens a menu of different 
  2043. ways to get around in the 
  2044. tutorial, as shown inA
  2045. the diagram at right.
  2046. Division by zero
  2047. Click
  2048.  Form_Click
  2049.  Counter = 0 
  2050.      
  2051. Print 1 / Counter
  2052.  Counter
  2053. End SubD
  2054. Proc:
  2055. Object:
  2056. A    LoanSheet%
  2057. Returns to theA
  2058. previous step.
  2059. OptionsX
  2060. +When you're done reading the Instructions, A$click the Close Instructions button.j
  2061. ,Click the Menu button ( > ) to return to the
  2062. +Learning Visual Basic Menu.  To exit, clickA
  2063. Options.w
  2064. -Click the Next button ( > ) to continue.  To 
  2065. *return to the Menu or exit Learning VisualA
  2066. Basic, click Options.
  2067. You can have Visual Basic 
  2068. place the Option Explicit 
  2069. !statement automatically in every 
  2070. form and module you create by 
  2071. choosing Environment from
  2072. the Options menu and setting
  2073. Require Variable Declaration@
  2074. to Yes.
  2075. DTo ensure that your application is free of bugs, you need to test it
  2076. (in a variety of situations; for example:
  2077. 4Use large and small values of numbers and strings.  
  2078. 2Often these reveal limitations in the application.
  2079. 8Ask other people to work with the application.  They may
  2080. 9find problems with its design or discover bugs you didn't
  2081. anticipate.
  2082. :If your application stores or retrieves data, check to see
  2083. *that the information is handled correctly.
  2084. +  Test how your application handles errors.@
  2085.  To insert a breakpoint, position
  2086. the cursor on the line of code
  2087. !where you want execution to stop.
  2088. Then choose Toggle Breakpoint
  2089. from the Debug menu, or choose
  2090. the Breakpoint button on the @
  2091. toolbar.
  2092. Compile errorso
  2093. 3-- mistakes that cause an incorrect result, or that
  2094. --@/ prevent your program from running as expected.
  2095. Compile errors
  2096. Compile errors are caused by
  2097. code that violates the rules of
  2098. the Visual Basic language.  @
  2099. These include syntax errors. 
  2100. Run-time errors
  2101. Logic errorsB
  2102. @?There are three types of errors you can make when writing code:&
  2103. [Form1.frm] ForeColor: 16776960)
  2104. A"Form1.ForeColor = RGB(0, 255, 255)
  2105. You can either go back and 
  2106. correct your mistake, press 
  2107. !and return to the error later, or
  2108. press 
  2109.  to get more information@
  2110. on the error.$
  2111. ear All Breakpoints5
  2112. A.How to Use the Learning Visual Basic Tutorial 5
  2113. A.How to Use the Learning Visual Basic Tutorial 
  2114. [Form1.frm] BackColor: 0@
  2115. [Form1.frm] BackColor: 0A
  2116. [Form1.frm] ForeColor: 16776960
  2117. ,This lesson discussed three types of errors:
  2118. Compile errors
  2119. Run-time errors
  2120. Logic errors
  2121. 'It also introduced the debugging tools 
  2122. available in Visual Basic.
  2123. &For more information about debugging, 
  2124. &see Chapter 9, ''Debugging,''  in the C
  2125. Programmer's Guide.;
  2126. To go forward in a lesson,A
  2127. click the Next button.  <
  2128. To go backward in a lesson,A
  2129. click the Back button.  @
  2130. --- mistakes caused by incorrectly constructed
  2131.  code.
  2132. (The example files needed for this lesson
  2133. )cannot be found.  To run this lesson, youA(need to reinstall Learning Visual Basic.
  2134. )You can't go back from this point in the 
  2135. %lesson.  To review the lesson, chooseA)Debugging Your Application from the Menu.!
  2136. Debugging Your Application
  2137. This lesson will cover:
  2138. Compile errors
  2139. Run-time errors
  2140. Logic errors
  2141. Visual Basic debugging tools
  2142. Expected: variable8
  2143. Closes the tutorial andA
  2144. returns to Visual Basic.j
  2145. A red arrow  
  2146. points to an instruction 
  2147. 'for you to follow to continue with the A    tutorial._
  2148. ,To return to the Learning Visual Basic Menu,A*press the SPACEBAR.  To exit, press ALT+O.
  2149. )Press the PAGE DOWN key to continue with 
  2150. (this lesson.  To choose another part of A.Learning Visual Basic or to exit, press ALT+O.
  2151. Procedure:
  2152. Module:
  2153. A    LoanSheet
  2154. A    ShowPmnts
  2155. CmdCalcPmts_Click
  2156. A    SizeCells    &Options
  2157. &Menu
  2158. &Show
  2159. &Close
  2160. &Back
  2161. &Instructions
  2162.     &Summary
  2163. E&xit Tutorial
  2164. Cancel: Esc
  2165. If (Age > 10 Then,
  2166.     form1.frm
  2167. formchi.frm
  2168. Return to &Menu
  2169. E&xit Learning VB
  2170. code.mak
  2171. mdinpad.frm
  2172. &Close Instructions
  2173. You can create
  2174. color schemes
  2175. that match 
  2176. your company'sA
  2177. logo.
  2178. Catalog
  2179. Summary:
  2180. Product Order Form
  2181. A    Inventory    
  2182. Search
  2183. Enter Item Number:
  2184. Border Lakes Real Estate
  2185. Index
  2186.  Property Type D
  2187. @AYou set the color properties of objects in the Properties window.
  2188. Product Sales
  2189. Specifications
  2190. A    Item No. 
  2191. Bronze
  2192. Units Sold
  2193. 8,200
  2194. Units Returned
  2195. 21,500
  2196. Net Unit Sales
  2197. -13,300
  2198. The property that 
  2199. you're setting.  
  2200. Properties that
  2201. use colors include 
  2202. BackColor,
  2203. ForeColor,
  2204. BorderColor, and A
  2205. FillColor.
  2206. Item No.
  2207. Diametery
  2208. BYou can define your own colors and add them to the Color palette. 
  2209. @0You can have up to 16 custom colors at one time.V
  2210. >Similarly, you can use different colors to identify different @
  2211. sections of a form.
  2212. Units EachH
  2213. Visual Basic saves your
  2214. custom colors from sessionA
  2215. to session. *
  2216. Please answer all A
  2217.      questions.
  2218. Product Ordering
  2219. Properties
  2220. Buyers
  2221. Opens this window.-
  2222. Jumps to the SummaryA
  2223. for that lesson.
  2224. Returns to the Menu.!
  2225. Closes the Options A
  2226. menu.    
  2227. Sellers
  2228. 0.375"+
  2229. A frame can containA
  2230. other controls.X
  2231. A picture box or an image
  2232. control can display a bitmap,A
  2233. an icon, or a metafile.D
  2234. Use white to show the fieldsA
  2235. in which you enter information.
  2236. Quantity
  2237. A    Cost Each
  2238. Total1
  2239. Use yellow to showA
  2240. the calculated fields.
  2241. )Press the PAGE DOWN key to continue with 
  2242. 'this lesson.  To choose another part ofA.Learning Visual Basic or to exit, press ALT+O.
  2243. Bin No.
  2244. Length
  2245. HEX7782A
  2246. 150,500
  2247. Auditor
  2248. Log No.
  2249. Wyatt
  2250. 5/4/91
  2251. WA-5B-91>
  2252. The blue section shows A
  2253. information about the product.:
  2254. The red section showsA
  2255. information about the audit.
  2256. =As you design your forms, try to avoid using too many colors.
  2257. >You'll have better results if you pick one group of colors and@
  2258. stick to them.
  2259. Production Outline
  2260. Length
  2261. Diameter
  2262. HEX7782A
  2263. Material
  2264. 1.25"
  2265. Material
  2266.  Price Range 
  2267. Item No.
  2268. CYou can also use Visual Basic code to change the color of an object
  2269. 0while your application is running.  For example:
  2270. <You can change the color of a field as soon as a user moves 
  2271. to that field.K
  2272. (In this form, one color is used for the A
  2273. background for all fields.
  2274. 1.25"
  2275. 0.375"    
  2276. Clicking the Options button 
  2277. opens a menu of different 
  2278. ways to get around in the 
  2279. tutorial, as shown inA
  2280. the diagram at right.
  2281. Bronzep
  2282. )Here, a different color is used for each 
  2283. 'field.  Notice how the form appears tooA
  2284. busy and distracting.
  2285. ?When designing applications that rely extensively on color, you
  2286. @may find it helpful to use a color guide or work with a designer@3to make the best use of color in your applications.
  2287. Buyer Survey
  2288. Community:
  2289. Residential Properties
  2290.     CondominiumM
  2291. A very small application
  2292.          created in A
  2293.      Visual Basic 2.0.
  2294. &This lesson discussed using color and 
  2295. +graphics in your Visual Basic applications.
  2296. %For more information on graphics, see
  2297. #Chapter 15, ''Creating Graphics for
  2298. Applications,'' in the
  2299.  Programmer's Guide.
  2300.     Undeveloped Land
  2301. A        House
  2302. AUsing color and graphics effectively is an art.  In the following
  2303. ?screens, we offer some basic tips on the different ways you can@
  2304. enhance your applications.m
  2305. =You can design custom command buttons for a form by attaching@+code to an image control or a picture box. 
  2306. John and Jane Homebuyer
  2307. Border Lakes
  2308. $50,000
  2309. Border Lakes
  2310.  txtSales_Change 
  2311.     If
  2312. txtSales.Text < 0 
  2313.         txtSales.ForeColor =
  2314.  RGB(
  2315. 255,0,0
  2316.     Else
  2317.         txtSales.ForeColor = 
  2318. 0,0,0
  2319.     End If
  2320. End Subt
  2321. This application 
  2322. displays a message 
  2323. and draws a box around 
  2324. a field if a user leaves A
  2325. that field empty.
  2326. Client Name:D
  2327. The Visual Basic language
  2328. can be used to draw otherA
  2329. shapes.R
  2330. MWith Visual Basic, you can easily add color and graphics to an application.  @
  2331. Product SalesO
  2332. >You can use Visual Basic code to display graphics in response @
  2333. to an event.
  2334. PAN3352AI
  2335. Lines and shapes can be
  2336. added to forms toA
  2337. emphasize information.5
  2338. You can create
  2339. arcs using theA
  2340. Circle method.G
  2341. You can create temporary
  2342. visual effects with the A
  2343. Line method.+
  2344. The object that A
  2345. you're working on.j
  2346. CAdding color to your forms and controls can make your applications @"more attractive and easier to use.A
  2347. You can use colors to 
  2348. emphasize important A
  2349. information.<
  2350. You choose a color fromA
  2351. the drop-down Color palette.
  2352. Using Color and Graphics
  2353. Form1 B
  2354. A    DrawWidth
  2355. A    BackColor
  2356. BorderStyle
  2357. Caption
  2358. ClipControls
  2359. ControlBox
  2360. DrawMode
  2361. A    DrawStyle
  2362. &H000040C0&
  2363. 2 - Sizable
  2364. Form1
  2365. 13 - Copy Pen
  2366. A    0 - Solid
  2367. Properties%
  2368. Returns to theA
  2369. previous step.
  2370. OptionsX
  2371. +When you're done reading the Instructions, A$click the Close Instructions button.w
  2372. -Click the Next button ( > ) to continue.  To 
  2373. *return to the Menu or exit Learning VisualA
  2374. Basic, click Options.
  2375. JGraphics methods in the Visual Basic language also let you create graphics
  2376. Hin your application.  Creating graphics with graphics methods is done in
  2377. Fcode, so these images appear on your form only when the application is@
  2378. running.b
  2379. 5You can make your forms easier to use by applying the@(same color to similar types of fields.  5
  2380. A.How to Use the Learning Visual Basic Tutorial 8
  2381. Closes the tutorial andA
  2382. returns to Visual Basic.5
  2383. A.How to Use the Learning Visual Basic Tutorial \
  2384.  txtItemNo_GotFocus 
  2385.      
  2386. txtItemNo.BackColor = &HFFFF&A
  2387. End Sub
  2388. CYou can also use Visual Basic code to change the color of an object
  2389. 0while your application is running.  For example:
  2390. <You can change the color of a field as soon as a user moves 
  2391. to that field.
  2392. <You can control the color of a value, depending upon whether
  2393.    @#that value is positive or negative.
  2394. Threads/in.
  2395. Each button on this form is 
  2396. an image control.  When a 
  2397. user clicks a picture, 
  2398. Visual Basic runs the code A
  2399. attached to that control.d
  2400. The Define Colors button 
  2401. displays a dialog box 
  2402. that allows you to select A
  2403. custom colors.
  2404. Johnson
  2405. Nut and Bolt, Inc.%
  2406. Product CatalogA
  2407. January, 1993;
  2408. To go forward in a lesson,A
  2409. click the Next button.  <
  2410. To go backward in a lesson,A
  2411. click the Back button.  O
  2412. @LGraphics can increase the usefulness of and add visual impact to your forms.
  2413. This lesson covers:
  2414. Using graphics
  2415. Using colors
  2416. &Changing graphics and colors with code
  2417.  @(Designing forms with graphics and colorsj
  2418. A red arrow  
  2419. points to an instruction 
  2420. 'for you to follow to continue with the A    tutorial.
  2421. About this Application    &Options
  2422. &Menu
  2423. Default
  2424. Custom Colors >>
  2425. Define Colors...
  2426. Search
  2427. Index
  2428. &Back
  2429. &Instructions
  2430.     &Summary
  2431. E&xit Tutorial
  2432. Cancel: Esc
  2433. &Close Instructions
  2434. p    u    p    
  2435. wwwwwwwwpwwwwwwwww
  2436. wwwwwwwwp
  2437. wwwwwwww
  2438. wwwwwwwwwwwwwwwwwwwwwwww
  2439. wwwwwwwwwwwwwwwwwwwwwwww
  2440. wwwwwwwwwwwwwwwwwwwwwwww
  2441. wwwwwwwwwwwwwwwwwwwwwwww
  2442. wwwwwwwwwwwwwwwwwwwwwwww
  2443. wwwwwwwwwwwwwwwwwwwwwwww
  2444. ;;;30
  2445. wwwwwwwp
  2446. wwwwwwp
  2447. wwwwwwwp
  2448. wwwwwwp
  2449. wwwwwwwp
  2450. wwwwwwp
  2451. wwwwwww
  2452. wwwwwww
  2453. wwwwwwwp
  2454. wwwwwww
  2455. wwwwwww
  2456. wwwwwwp
  2457. wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
  2458. wwwwwwwp
  2459. wwwwwwp
  2460. wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
  2461. wwwwwwwwp
  2462. wwwwwwwwp
  2463. wwwwwwx
  2464.